// JavaScript Document

function chkallClick(o) {
	
	var form = document.formList;
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
			form.elements[i].checked = document.formList.chkall.checked;
		}
	}
}
function Today()
{
	var today = new Date();
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1;
	var day = currentTime.getDate();
	var year = currentTime.getFullYear();
	if (language_code == "en")
		return year+'-'+month+'-'+day;
	else
		return day+'.'+month+'.'+year;
}
function JQueryGridToFrom(data,form)
{
	if (data) {
		for(var i in rowdata) {
			// this is very slow on big table and form.
			$("[name="+i+"]",formid).val(rowdata[i]);
		}
	}
}
function ShowMsgBox(msg,result,id)
{
	if(id==null) id = "#msgbox";
	$(id).removeClass().addClass('messagebox').text('Progress....').fadeIn(1000);
	$(id).fadeTo(200,0.1,function() //start fading the messagebox
	{
	  //add message and change the class of the box and start fading
	  $(this).html(msg);
	  if(result) $(this).addClass('messageboxok').fadeTo(900,1); else $(this).addClass('messageboxerror').fadeTo(900,1);
	});
}
function JQueryShowHide(id)
{
	$(id).toggle();	
}
function ShowHide(id)
{	
	o = document.getElementById(id);
	if(o.style.display!='none')
	{
		o.style.display='none';
	}
	else
	{
		if(navigator.appName=='Netscape')
			o.style.display='block';
		else
			o.style.display='block';
	}
}	

function selectAll(checkvalue)
	{
		var elements = document.getElementById('mainform').elements;
		for (i=0; i<elements.length; i++)
		{
			if (elements[i].id == "checkbox")
				elements[i].checked = checkvalue;
		}
		
	}
function div_ShowHide(id)
{
	dis_stat = document.getElementById(id).style.display;
	if(dis_stat == 'none')
		document.getElementById(id).style.display = "block";
	else
		document.getElementById(id).style.display = "none";
		
}
function showResponse(data, status)  { 
	 if(data.indexOf("Success") != -1) 
	{	
		ShowMsgBox(data,true);
	} 
	else 
	{
		ShowMsgBox(data,false);
	}
	return true;
} 
function showResponse2(data, status)  { 
	
	var data = data.responseText;
	if(data.indexOf("Success") != -1) 
	{	
		ShowMsgBox(data,true);
	} 
	else 
	{
		ShowMsgBox(data,false);
	}
	return true;
} 

function checkOption(select_id,value)
	{
		var arrOptions = document.getElementById(select_id).options;
		for (i=0;i<arrOptions.length;i++)
			if (arrOptions[i].value==value)
				arrOptions[i].selected = true;
			else
				arrOptions[i].selected = false;
	}
	